package com.zzzy.framework.dto;

import com.zzzy.framework.common.enums.sys.DataScopeEnum;
import lombok.Data;

import java.util.Objects;
import java.util.Set;

@Data
public class DataPermissionDto {

    /**
     * 数据权限
     */
    private Integer dataPermission;

    /**
     * 管理的用户集合
     */
    private Set<Long> userIdSet;

    public DataPermissionDto(Integer dataPermission) {
        this.dataPermission = dataPermission;
    }

    public DataPermissionDto(Integer dataPermission, Set<Long> userIdSet) {
        this.dataPermission = dataPermission;
        this.userIdSet = userIdSet;
    }
    public boolean manageUser(Long userId) {
        return DataScopeEnum.ALL.getValue().equals(dataPermission) || (Objects.nonNull(userIdSet) && userIdSet.contains(userId));
    }
}
